#include <iostream>

#include <gtest/gtest.h>

#include "melon/client/thrift_client_pool.h"
#include "bbt/adapters/bbt_engineer_counter_adapter.h"

using melon::client::ClientPool;

using namespace bbt;

TEST(T, Add) {
  int ret = BbtEngineerCounterAdapter::Instance().Increment(10002, CounterType::SHARED, 3, 1);
  EXPECT_EQ(ret, 1);
}

struct Args {
  Args(int c, char ** v) : argc(c), argv(v) {}
  int argc;
  char** argv;
};

void * ThreadFun(void * p) {
  Args * args = (Args*)p;
  testing::InitGoogleTest(&args->argc, args->argv);
  return (void*)RUN_ALL_TESTS();
}

const int kThreadCount = 1;

int main(int argc, char ** argv) {
  LOG_INIT("./test.log", "DEBUG");
  pthread_t ts[kThreadCount];
  Args args(argc, argv); 
  for (int i = 0; i < kThreadCount; ++i) {
    pthread_create(&ts[i], NULL, ThreadFun, &args);
  }

  for (int i = 0; i < kThreadCount; ++i) {
    pthread_join(ts[i], NULL);
  }
  return 0;
} 

